import { Component } from "react";
import {unstable_batchedUpdates} from 'react-dom'

class Aaa extends Component {
    constructor() {
        super()
        this.state = {
            count: 0
        }
    }

    changeCount = () => {
        Promise.resolve().then(() => {
            unstable_batchedUpdates(() => {
                this.setState({ count: this.state.count + 1 })
                console.log(this.state.count)
                this.setState({ count: this.state.count + 1 })
                console.log(this.state.count)
            })
        })
    }

    render() {
        return (
            <div>
            <p>{this.state.count}</p>
            <button onClick={this.changeCount}>+ 1</button>
        </div>
        )
    }
}

export default Aaa